package org.bringer.service;

import java.util.List;

import javax.jws.WebService;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.bringer.model.Account;
import org.bringer.service.exceptions.AccountExistsException;

/**
 * Web Service interface so hierarchy of Generic Manager isn't carried through.
 */
@WebService
@Path("/accounts")
public interface AccountService {
    /**
     * Retrieves a account by accountId.  An exception is thrown if account not found
     *
     * @param accountId the identifier for the account
     * @return Account
     */
    @GET
    @Path("/getAccount/{id}")    
    @Produces(MediaType.APPLICATION_XML)
    Account getAccount(@PathParam("id") String accountId);

    /**
     * Finds a account by their accountname.
     *
     * @param ibanCode The iban code
     * @return Account a populated account object
     */
    @GET
    @Path("/getAccountByIban/{ibanCode}")
    @Produces(MediaType.APPLICATION_XML)
    Account getAccountByIban(@PathParam("ibanCode") String ibanCode);

    

    /**
     * Saves a account's information
     *
     * @param account the account's information
     * @return updated account
     * @throws AccountExistsException thrown when account already exists
     */
    @POST
    @Path("/saveAccount")
    Account saveAccount(Account account) throws AccountExistsException;

    /**
     * Removes a account from the database by their accountId
     *
     * @param accountId the account's id
     */
    @DELETE
    @Path("/removeAccount")
    void removeAccount(String accountId);
    
    @GET
    @Path("/getAccountsByUser/{userId}")
    List<Account> getAccountsByUser(@PathParam("userId") String userId);
}
